import { NextResponse } from "next/server"

import prisma from "@/lib/prisma"

export const GET = async (req: Request, { params }: { params: { messageId: string } }) => {
    const data = await prisma.chatMessage.findUnique({
        where: { id: params.messageId }
    })
    return NextResponse.json(data)
}

export const PUT = async (req: Request, { params }: { params: { messageId: string } }) => {
    const body = await req.json()
    const data = await prisma.chatMessage.update({
        where: { id: params.messageId },
        data: body
    })

    return NextResponse.json(data)
}

export const DELETE = async (req: Request, { params }: { params: { messageId: string } }) => {
    const data = await prisma.chatMessage.delete({
        where: { id: params.messageId }
    })
    return NextResponse.json(data)
}